// src/api/api.ts
import request from "@/utils/request";

/**
 * 新建或者更新员工
 * @param data
 * @returns
 */
export const addEmployeeApi = (data: any) => {
  return request({
    url: "/api/employee/saveOrUpdate",
    method: "POST",
    data: data,
  });
};

/**
 * 获取员工列表
 * @param params
 * @returns
 */
export const getEmployeeListApi = (params: any) => {
  return request({
    url: "/api/employee/list",
    method: "GET",
    params: params,
  });
};

/**
 * 删除员工
 * @param id '员工id'
 * @returns
 */
export const deleteEmployeeApi = (id: number) => {
  return request({
    url: `/api/employee/delete/${id}`,
    method: "DELETE",
  });
};

/**
 * 修改员工是否为管理员
 * @param id '员工id'
 * @returns
 */
export const changeEmployeeAdminApi = (data: any) => {
  return request({
    url: "/api/employee/updateState",
    method: "POST",
    data: data,
  });
};

/**
 * 获取员工角色
 * @param id '员工id'
 * @returns
 */
export const getRoleByIdApi = (id: number) => {
  return request({
    url: `/api/role/getEmployeeRole/${id}`,
    method: "GET",
  });
};
